package org.wk.common.jpush.vo;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;

import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * @author df.wu
 * @version V1.0
 * @title: Custom
 * @package com.athena.base.service.vo
 * @Date 9:36 2017/11/24
 * @description:
 */
public class CustomAudienceTarget {

    private String audienceType;
    private Set<String> values;

    public CustomAudienceTarget() {}

    public CustomAudienceTarget(CustomAudienceType audienceType) {
        this.audienceType = audienceType.getValue();
    }

    public CustomAudienceTarget(CustomAudienceType audienceType, Set<String> values) {
        this.audienceType = audienceType.getValue();
        this.values = values;
    }

    public static CustomAudienceTarget tag(String... tag) {
        return new CustomAudienceTarget().setAudienceType(CustomAudienceType.TAG).addAudienceTargetValues(tag);
    }

    public static CustomAudienceTarget tag(Collection<String> tags) {
        return new CustomAudienceTarget().setAudienceType(CustomAudienceType.TAG).addAudienceTargetValues(tags);
    }

    public static CustomAudienceTarget tag_and(String... tag) {
        return new CustomAudienceTarget().setAudienceType(CustomAudienceType.TAG_AND).addAudienceTargetValues(tag);
    }

    public static CustomAudienceTarget tag_and(Collection<String> tags) {
        return new CustomAudienceTarget().setAudienceType(CustomAudienceType.TAG_AND).addAudienceTargetValues(tags);
    }

    public static CustomAudienceTarget tag_not(String... tag) {
        return new CustomAudienceTarget().setAudienceType(CustomAudienceType.TAG_NOT).addAudienceTargetValues(tag);
    }

    public static CustomAudienceTarget tag_not(Collection<String> tags) {
        return new CustomAudienceTarget().setAudienceType(CustomAudienceType.TAG_NOT).addAudienceTargetValues(tags);
    }

    public static CustomAudienceTarget alias(String... alias) {
        return new CustomAudienceTarget().setAudienceType(CustomAudienceType.ALIAS).addAudienceTargetValues(alias);
    }

    public static CustomAudienceTarget alias(Collection<String> aliases) {
        return new CustomAudienceTarget().setAudienceType(CustomAudienceType.ALIAS).addAudienceTargetValues(aliases);
    }

    public static CustomAudienceTarget registrationId(String... registrationId) {
        return new CustomAudienceTarget().setAudienceType(CustomAudienceType.REGISTRATION_ID).addAudienceTargetValues(registrationId);
    }

    public static CustomAudienceTarget registrationId(Collection<String> registrationIds) {
        return new CustomAudienceTarget().setAudienceType(CustomAudienceType.REGISTRATION_ID).addAudienceTargetValues(registrationIds);
    }

    public static CustomAudienceTarget segment(String... segment) {
        return new CustomAudienceTarget().setAudienceType(CustomAudienceType.SEGMENT).addAudienceTargetValues(segment);
    }

    public static CustomAudienceTarget segment(Collection<String> segments) {
        return new CustomAudienceTarget().setAudienceType(CustomAudienceType.SEGMENT).addAudienceTargetValues(segments);
    }

    public static CustomAudienceTarget abTest(String... abTestId) {
        return new CustomAudienceTarget().setAudienceType(CustomAudienceType.ABTEST).addAudienceTargetValues(abTestId);
    }

    public static CustomAudienceTarget abTest(Collection<String> abTestIds) {
        return new CustomAudienceTarget().setAudienceType(CustomAudienceType.ABTEST).addAudienceTargetValues(abTestIds);
    }

    public String getAudienceType() {
        return audienceType;
    }

    public Set<String> getValues() {
        return values;
    }

    public CustomAudienceTarget setAudienceType(CustomAudienceType customAudienceType) {
        this.audienceType = customAudienceType.getValue();
        return this;
    }

    public void setValues(Set<String> values) {
        this.values = values;
    }

    public CustomAudienceTarget addAudienceTargetValues(Collection<String> values) {
        if (null == this.values) {
            this.values = new HashSet();
        }

        Iterator var2 = values.iterator();

        while(var2.hasNext()) {
            String value = (String)var2.next();
            this.values.add(value);
        }

        return this;
    }

    public CustomAudienceTarget addAudienceTargetValues(String... values) {
        if (null == this.values) {
            this.values = new HashSet();
        }
        String[] var2 = values;
        int var3 = values.length;
        for(int var4 = 0; var4 < var3; ++var4) {
            String value = var2[var4];
            this.values.add(value);
        }
        return this;
    }

}
